home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!marnold
- From: marnold@netcom.com (Matt Arnold)
- Subject: Re: Pure virtual destructors?
- Message-ID: <marnoldDpxy4K.1wv@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <4kuq0i$p6t@ftp.ee.vill.edu> <marnoldDpxt3n.F12@netcom.com>
- Date: Tue, 16 Apr 1996 06:02:44 GMT
- Sender: marnold@netcom19.netcom.com
-
- marnold@netcom.com (Matt Arnold) writes:
-
- >sheridan@monet.vill.edu writes:
-
-
- >>The rule with destructors is that they are always overridden, right?
- >>That's a quote from VC4 docs, BTW. When I do this:
-
- >>class CBase {
- >>public:
- >> virtual ~CBase() = 0;
- >>...};
-
- >>class CChild : public CBase {
- >>public:
- >> ~CChild();
- >>...};
-
- >>and declare a body for ~CChild, I always get unresolved external on
- >>CBase::~CBase. I have seen this in several cases. My guess is it's not
- >>a compiler bug, so what am I missing?
-
- >You're missing the fact that virtual destructors are *always* called,
- >even pure ones (in your example, before ~CChild is executed, ~CBase
-
- Whoa! I said that backwards!!! The "Reverse" key on my terminal
- must have been stuck down.
-
- That above should have been "~CBase will always be executed before
- ~CChild executes, no matter what". Since, of course, objects in
- C++ are always destroyed in exactly the opposite order of their
- construction. Sorry for any confusion.
-
- >*will* be executed no matter what). You get link errors because the
- >compiler is looking for the CBase::~CBase() you forgot to define.
-
-
- -------------------------------------------------------------------------
- Matt Arnold | | ||| | |||| | | | || ||
- marnold@netcom.com | | ||| | |||| | | | || ||
- Boston, MA | 0 | ||| | |||| | | | || ||
- 617.389.7384 (h) 617.576.2760 (w) | | ||| | |||| | | | || ||
- C++, MIDI, Win32/95 developer | | ||| 4 3 1 0 8 3 || ||
- -------------------------------------------------------------------------
-